<html>
<head>
  <script>
    if (window.testRunner) {
        testRunner.dumpAsText();
        testRunner.dumpChildFrames();
        testRunner.waitUntilDone();
        testRunner.clearBackForwardList();
    }

    function renameSubframeAndTriggerNavigations() {
        setTimeout(function() {
            // Make sure the child navigation only happens once.
            if (sessionStorage.alreadyRenamedSubframeAndTriggeredNavigations)
                return;
            sessionStorage.alreadyRenamedSubframeAndTriggeredNavigations = true;

            // Rename the child window.  Without this step,
            // https://crbug.com/607205 wouldn't repro.
            var childWindow = document.getElementById("child").contentWindow;
            childWindow.name = "changed-name";

            // Navigate the child window and tell resources/form-target.pl
            // what it should do after a load.
            sessionStorage.formTargetShouldNavAndGoBack = true;
            childWindow.location = "resources/page-that-posts.html";
        }, 0);
    }
  </script>
</head>
<body onload="renameSubframeAndTriggerNavigations();">
<p>Tests that session history works even if the page changes frame names after initial load.</p>
<br>
<iframe id="child" name="initial-name" src="resources/otherpage.html"></iframe>
</body>
</html>
